<template><div><h2 id="进入到网卡配置文件目录" tabindex="-1"><a class="header-anchor" href="#进入到网卡配置文件目录"><span>进入到网卡配置文件目录</span></a></h2>
<div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#282c34;color:#abb2bf"><pre class="shiki one-dark-pro vp-code" v-pre=""><code><span class="line"><span style="color:#56B6C2">cd</span><span style="color:#98C379"> /etc/sysconfig/network-scripts/</span></span>
<span class="line"><span style="color:#61AFEF">ls</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="选择并编辑网卡文件" tabindex="-1"><a class="header-anchor" href="#选择并编辑网卡文件"><span>选择并编辑网卡文件</span></a></h2>
<div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#282c34;color:#abb2bf"><pre class="shiki one-dark-pro vp-code" v-pre=""><code><span class="line"><span style="color:#61AFEF">sudo</span><span style="color:#98C379"> vi</span><span style="color:#98C379"> /etc/sysconfig/network-scripts/ifcfg-ens33</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2 id="配置说明" tabindex="-1"><a class="header-anchor" href="#配置说明"><span>配置说明</span></a></h2>
<div class="language-shell line-numbers-mode has-collapsed-lines collapsed" data-highlighter="shiki" data-ext="shell" style="--vp-collapsed-lines:15;background-color:#282c34;color:#abb2bf"><pre class="shiki one-dark-pro vp-code" v-pre=""><code><span class="line"><span style="color:#E06C75">TYPE</span><span style="color:#56B6C2">=</span><span style="color:#98C379">Ethernet</span><span style="color:#61AFEF">                        //网络类型：Ethernet以太网</span></span>
<span class="line"><span style="color:#E06C75">BOOTPROTO</span><span style="color:#56B6C2">=</span><span style="color:#98C379">none</span><span style="color:#61AFEF">                       //引导协议：自动获取、static静态、none不指定</span></span>
<span class="line"><span style="color:#E06C75">DEFROUTE</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span><span style="color:#61AFEF">                         //启动默认路由</span></span>
<span class="line"><span style="color:#E06C75">IPV4_FAILURE_FATAL</span><span style="color:#56B6C2">=</span><span style="color:#98C379">no</span><span style="color:#61AFEF">                //不启用IPV4错误检测功能</span></span>
<span class="line"><span style="color:#E06C75">IPV6INIT</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span><span style="color:#61AFEF">                         //启用IPV6协议</span></span>
<span class="line"><span style="color:#E06C75">IPV6_AUTOCONF</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span><span style="color:#61AFEF">                    //自动配置IPV6地址</span></span>
<span class="line"><span style="color:#E06C75">IPV6_DEFROUTE</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span><span style="color:#61AFEF">                    //启用IPV6默认路由</span></span>
<span class="line"><span style="color:#E06C75">IPV6_FAILURE_FATAL</span><span style="color:#56B6C2">=</span><span style="color:#98C379">no</span><span style="color:#61AFEF">                //不启用IPV6错误检测功能</span></span>
<span class="line"><span style="color:#E06C75">NAME</span><span style="color:#56B6C2">=</span><span style="color:#98C379">eno16777736</span><span style="color:#61AFEF">                     //</span><span style="color:#98C379"> 网卡设备的别名</span></span>
<span class="line"><span style="color:#E06C75">UUID</span><span style="color:#56B6C2">=</span><span style="color:#98C379">90528772-9967-46da-b401-f82b64b4acbc</span><span style="color:#61AFEF">         //网卡设备的UUID唯一标识号</span></span>
<span class="line"><span style="color:#E06C75">DEVICE</span><span style="color:#56B6C2">=</span><span style="color:#98C379">eno16777736</span><span style="color:#61AFEF">                   //</span><span style="color:#98C379"> 网卡的设备名称</span></span>
<span class="line"><span style="color:#E06C75">ONBOOT</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span><span style="color:#61AFEF">                           //开机自动激活网卡</span></span>
<span class="line"><span style="color:#E06C75">DNS1</span><span style="color:#56B6C2">=</span><span style="color:#98C379">6.6.6.6</span><span style="color:#61AFEF">                         //DNS域名解析服务器的IP地址</span></span>
<span class="line"><span style="color:#E06C75">IPADDR</span><span style="color:#56B6C2">=</span><span style="color:#98C379">192.168.1.199</span><span style="color:#61AFEF">                 //网卡的IP地址</span></span>
<span class="line"><span style="color:#E06C75">PREFIX</span><span style="color:#56B6C2">=</span><span style="color:#98C379">24</span><span style="color:#61AFEF">                            //子网掩码</span></span>
<span class="line"><span style="color:#E06C75">GATEWAY</span><span style="color:#56B6C2">=</span><span style="color:#98C379">192.168.1.1</span><span style="color:#61AFEF">                  //默认网关IP地址</span></span>
<span class="line"><span style="color:#E06C75">IPV6_PEERDNS</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span></span>
<span class="line"><span style="color:#E06C75">IPV6_PEERROUTES</span><span style="color:#56B6C2">=</span><span style="color:#98C379">yes</span></span>
<span class="line"><span style="color:#E06C75">IPADDR</span><span style="color:#56B6C2">=</span><span style="color:#98C379">192.168.2.2</span><span style="color:#7F848E;font-style:italic">             #你想要设置的固定IP，理论上192.168.2.2-255之间都可以，请自行验证；</span></span>
<span class="line"><span style="color:#E06C75">NETMASK</span><span style="color:#56B6C2">=</span><span style="color:#98C379">255.255.255.0</span><span style="color:#7F848E;font-style:italic">          #子网掩码，不需要修改；</span></span>
<span class="line"><span style="color:#E06C75">GATEWAY</span><span style="color:#56B6C2">=</span><span style="color:#98C379">192.168.2.1</span><span style="color:#7F848E;font-style:italic">            #网关，这里是你在“2.配置虚拟机的NAT模式具体地址参数”中的</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div><div class="collapsed-lines"></div></div><h2 id="重启网卡生效" tabindex="-1"><a class="header-anchor" href="#重启网卡生效"><span>重启网卡生效</span></a></h2>
<div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#282c34;color:#abb2bf"><pre class="shiki one-dark-pro vp-code" v-pre=""><code><span class="line"><span style="color:#61AFEF">systemctl</span><span style="color:#98C379"> restart</span><span style="color:#98C379"> network</span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div></div></template>


